package com.haoze.message.controller;


import com.haoze.common.response.Result;
import com.haoze.common.response.ResultGenerator;
import com.haoze.message.message.WebSocketHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/socket")
@Api(value = "socket消息通讯")
@Validated
public class SocketMessageController {

    @Autowired
    private WebSocketHandler webSocketHandler;

    @GetMapping("/sendmsg")
    @ApiOperation(value = "发送socket消息给客户端")
    public Result sendMsg(@RequestParam final String account,@RequestParam final String msg) {
        webSocketHandler.sendMessage(account,msg);
        return ResultGenerator.genOkResult();
    }
}
